package com.ywang.puremvc.impl;

import java.util.Hashtable;

import com.ywang.puremvc.framework.IModel;
import com.ywang.puremvc.framework.IProxy;

/**
 * @author ywang
 */
public class Model implements IModel {
    
    private static Model instance;
    
    private Hashtable<String, IProxy> proxys;
    
    public static Model getInstance() {
        if (instance == null)
            instance = new Model();
        
        return instance;
    }
    
    private Model() {
        proxys = new Hashtable<String, IProxy>();
    }
    
    @Override
    public void registerProxy(IProxy proxy) {
        if (proxy != null)
            proxys.put(proxy.getProxyName(), proxy);
    }

    @Override
    public IProxy retrieveProxy(String name) {
        return proxys.get(name);
    }

    @Override
    public void removeProxy(String name) {
        proxys.remove(name);
    }
}
